<?php

	$file = $_GET['file'];
	$file_extension = strtolower(substr(strrchr($file,"."),1));
	
	if ((isset($file))&&(file_exists($file))) {
		switch( $file_extension ) {
			case "pdf": $ctype="application/pdf"; break;
			case "exe": $ctype="application/octet-stream"; break;
		}
	}
	
	header("Pragma: public"); // required
	header("Expires: 0");
	header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
	header("Cache-Control: private",false); // required for certain browsers
	header("Content-type: application/force-download");
	header('Content-Disposition: inline; filename="' .$file . '"');
	header("Content-Transfer-Encoding: Binary");
	header("Content-length: ".filesize($file));
	
	header("Content-Type: $ctype");
	header('Content-Disposition: attachment; filename="' . $file . '"');
	
	readfile("$file");

?>